package cn.hwua.web;

import cn.hwua.dao.CompanyDao;
import cn.hwua.dao.impl.CompanyDaoImpl;
import cn.hwua.entity.Company;
import org.apache.taglibs.standard.extra.spath.Step;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/company/*")
public class CompanyServlet extends HttpServlet {
    private CompanyDao dao=new CompanyDaoImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String baseURL=req.getContextPath();//获取项目的基本路径
        String uri=req.getRequestURI();
        String path=uri.substring(uri.lastIndexOf("/")+1);
        System.out.println("path = " + path);
        if ("list.do".equals(path)){
            List<Company> companyList = dao.findAll();
            req.setAttribute("companyList",companyList);
            req.getRequestDispatcher(baseURL+"/pc/about-us.jsp").forward(req,resp);
            return;
        }
    }
}
